class Account
  include MongoMapper::Document
  
  key :name, String, :unique => true
  key :friend_ids,  Array
  key :follower_ids,  Array
  key :created_on, Time

  validates_presence_of :name
  
  many :keywords
  many :tweeters
  
  before_save :set_defaults
  
  def set_defaults
    if self.created_on == nil
      self.created_on = Time.now
    end
    
    if self.follower_ids == nil
      self.follower_ids = ""
    end
    
    if self.friend_ids == nil
      self.friend_ids = ""
    end
  end
  
  def to_s
    return self.to_yaml
  end
end